const axios = require('axios')
const getAccess = require('../model/get_access_token')

module.exports = async (req, res, next) => {
	let accessToken = await getAccess.fetchAccessToken();
	axios.post(`https://api.weixin.qq.com/cgi-bin/menu/create?access_token=${accessToken.access_token}`,
		data = {	

			"button": [{
				"name": "扫码",
				"type": "click",
				"sub_button": [{
					"type": "scancode_waitmsg",
					"name": "扫码带提示",
					"key": "rselfmenu_0_0",
					"sub_button": []
				},
				{
					"type": "scancode_push",
					"name": "扫码推事件",
					"key": "rselfmenu_0_1",
					"sub_button": []
				}
				]
			},
			{
				"name": "发图",
				"type": "click",
				"sub_button": [{
					"type": "pic_sysphoto",
					"name": "系统拍照发图",
					"key": "rselfmenu_1_0",
					"sub_button": []
				},
				{
					"type": "pic_photo_or_album",
					"name": "拍照或者相册发图",
					"key": "rselfmenu_1_1",
					"sub_button": []
				},
				{
					"type": "pic_weixin",
					"name": "微信相册发图",
					"key": "rselfmenu_1_2",
					"sub_button": []
				}
				]
			},
			{
				"name": "位置相关",
				"type": "click",
				"sub_button": [{
					"name": "发送位置",
					"type": "location_select",
					"key": "rselfmenu_2_0",
					"sub_button": []
				},
				{
					"type": "view",
					"name": "视频",
					"url": "http://v.qq.com/",
					"sub_button": []
				},
				{
					"type": "view",
					"name": "首页",
					"url": "http://store.liufengmao.cn:3001/wechat",
					"sub_button": []
				}]
			}
			]

		}
	).then(res => {
		console.log('设置菜单', res.data)
	})
}